<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{padding:0;margin:0;}
        .header{height: 20px;background-color: rgba(0, 0, 0, .6);
            /* 通过渲染进程 移动app：-webkit-app-region */
            -webkit-app-region:drag;
        }
        .mini,.close{float:right;width: 30px;display: inline-block;text-align: center;color: white;-webkit-app-region:no-drag;}
    </style>
    <script src="./vue.js"></script>
</head>

<body>
    <div id="app">
        <div class="header">
            <span class="close" @click="close">x</span>
            <span class="mini" @click="mini">-</span>
        </div>
        <div class="body">
            <p>Add a todo <input type="text" v-model="todoMes"/><button @click="add">Add</button></p>
            <ul>
                <li v-for="(item,index) of todoList" :key="index">{{item}}<button @click="del(index)">delete</button></li>
            </ul>
        </div>
    </div>
    <script>
        const {remote} = require('electron')
        new Vue({
            el: '#app',
            data: {
                todoList: [
                    '11111', '2222','33333'
                ],
                todoMes:''
            },
            methods:{
                add(){
                    if(!!this.todoMes.trim()){
                        this.todoList.push(this.todoMes)
                        this.todoMes = ''
                    }
                }
                ,del(i){
                    this.todoList.splice(i,1)
                }
                ,close(){
                    remote.app.exit()
                }
                ,mini(){
                    // remote.getCurrentWindow() 获取当前窗口 BrowserWindow
                    remote.getCurrentWindow().minimize()
                }
            }
        })
    </script>
</body>

</html>